<?php
//list
if (isset($_POST['memlist'])) {
$controlmsg = new xmlrpcmsg('atheme.command');
				$controlmsg->addParam(new xmlrpcval($authcookie, $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($uname, $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval(".", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval("MemoServ", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval("LIST", $xmlrpcString));
			$client = new xmlrpc_client(PATH, HOST, PORT);
			$controlresponse = $client->send($controlmsg);
			if($controlresponse->faultCode()) {
				printf('<h3>Fault</h3>');
				printf('Fault code: %d<br>', htmlentities($controlresponse->faultCode()));
				printf('Fault string: %s', htmlentities($controlresponse->faultString()));

				}else{ 
				echo $controlresponse->serialize(); }

				}
				
//Read Process
if (isset($_POST['readnum'])) {
$controlmsg = new xmlrpcmsg('atheme.command');
				$controlmsg->addParam(new xmlrpcval($authcookie, $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($uname, $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval(".", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval("MemoServ", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval("READ", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($_POST['readnum'], $xmlrpcString));
			$client = new xmlrpc_client(PATH, HOST, PORT);
			$controlresponse = $client->send($controlmsg);
			if($controlresponse->faultCode()) {
				printf('<h3>Fault</h3>');
				printf('Fault code: %d<br>', htmlentities($controlresponse->faultCode()));
				printf('Fault string: %s', htmlentities($controlresponse->faultString()));

				}else{ 
				echo $controlresponse->serialize(); }

				}
				
//Send Process
if (isset($_POST['sendnick']) && isset($_POST['sendmsg'])) {
$controlmsg = new xmlrpcmsg('atheme.command');
				$controlmsg->addParam(new xmlrpcval($authcookie, $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($uname, $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval(".", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval("MemoServ", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval("SEND", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($_POST['sendnick'], $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($_POST['sendmsg'], $xmlrpcString));
			$client = new xmlrpc_client(PATH, HOST, PORT);
			$controlresponse = $client->send($controlmsg);
			if($controlresponse->faultCode()) {
				printf('<h3>Fault</h3>');
				printf('Fault code: %d<br>', htmlentities($controlresponse->faultCode()));
				printf('Fault string: %s', htmlentities($controlresponse->faultString()));

				}else{ 
				echo $controlresponse->serialize(); }

				}	

//Delete Process
if (isset($_POST['delnum'])) {
$controlmsg = new xmlrpcmsg('atheme.command');
				$controlmsg->addParam(new xmlrpcval($authcookie, $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($uname, $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval(".", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval("MemoServ", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval("DELETE", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($_POST['delnum'], $xmlrpcString));
			$client = new xmlrpc_client(PATH, HOST, PORT);
			$controlresponse = $client->send($controlmsg);
			if($controlresponse->faultCode()) {
				printf('<h3>Fault</h3>');
				printf('Fault code: %d<br>', htmlentities($controlresponse->faultCode()));
				printf('Fault string: %s', htmlentities($controlresponse->faultString()));

				}else{ 
				echo $controlresponse->serialize(); }

				}					
				
//Forward Process
if (isset($_POST['fwdnick']) && isset($_POST['fwdnum'])) {
$controlmsg = new xmlrpcmsg('atheme.command');
				$controlmsg->addParam(new xmlrpcval($authcookie, $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($uname, $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval(".", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval("MemoServ", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval("FORWARD", $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($_POST['fwdnick'], $xmlrpcString));
				$controlmsg->addParam(new xmlrpcval($_POST['fwdnum'], $xmlrpcString));
			$client = new xmlrpc_client(PATH, HOST, PORT);
			$controlresponse = $client->send($controlmsg);
			if($controlresponse->faultCode()) {
				printf('<h3>Fault</h3>');
				printf('Fault code: %d<br>', htmlentities($controlresponse->faultCode()));
				printf('Fault string: %s', htmlentities($controlresponse->faultString()));

				}else{ 
				echo $controlresponse->serialize(); }

				}						
				
							
								
				
					
											
				
				
?>
<?php if (isset($_POST['infochan']) || isset($_POST['flistchan']) || isset($_POST['memlist']) || isset($_POST['readnum'])){ echo "</pre>"; } ?>
<h1>MemoServ</h1>
<hr />
<a href="#" onclick="showhide('div1');"><h3>List</h3></a>
<div id="div1" style="display: none;">
<form method="post" action="<?php echo $PHP_SELF;?>"> 
<input type="submit" value="List Memos!" name="memlist">
</form>
</div>

<a href="#" onclick="showhide('div2');"><h3>Read</h3></a>
<div id="div2" style="display: none;">
<form method="post" action="<?php echo $PHP_SELF;?>"> 
Memo Number<br />
<input type="text" size="5" maxlength="5" name="readnum"><br />
<input type="submit" value="Read!" name="submit">
</form>
</div>

<a href="#" onclick="showhide('div3');"><h3>Delete</h3></a>
<div id="div3" style="display: none;">
<form method="post" action="<?php echo $PHP_SELF;?>"> 
Memo Number<br />
<input type="text" size="5" maxlength="5" name="delnum"><br />
<input type="submit" value="Delete!" name="submit">
</form>
</div>

<a href="#" onclick="showhide('div4');"><h3>Send</h3></a>
<div id="div4" style="display: none;">
<form method="post" action="<?php echo $PHP_SELF;?>"> 
Nick/User<br />
<input type="text" size="12" maxlength="15" name="sendnick"><br />
Message<br />
<input type="text" size="100" maxlength="300" name="sendmsg"><br />
<input type="submit" value="Send!" name="submit">
</form>
</div>

<a href="#" onclick="showhide('div5');"><h3>Forward</h3></a>
<div id="div5" style="display: none;">
<form method="post" action="<?php echo $PHP_SELF;?>"> 
Nick/User<br />
<input type="text" size="12" maxlength="15" name="fwdnick"><br />
Memo Number<br />
<input type="text" size="5" maxlength="5" name="fwdnum"><br />
<input type="submit" value="Forward!" name="submit">
</form>
</div>
